<!DOCTYPE html>
<html>
<head>
    <title>登录</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }
        .login-container {
            background: white;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            width: 300px;
        }
        h1 {
            text-align: center;
            color: #333;
            margin-bottom: 1.5rem;
        }
        label {
    <div class="login-container">
        <h1>登录</h1>
        <form id="loginForm">
            <label>用户名:</label>
            <input type="text" name="username" required>
            <label>密码:</label>
            <input type="password" name="password" required>
            <button type="submit">登录</button>
        </form>
        <div id="result"></div>
    </div>
            display: block;
            margin-bottom: 0.5rem;
            color: #555;
        }
        input {
            width: 100%;
            padding: 0.5rem;
            margin-bottom: 1rem;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button {
            width: 100%;
            padding: 0.75rem;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 1rem;
        }
        button:hover {
            background-color: #45a049;
        }
        #result {
            margin-top: 1rem;
            padding: 0.5rem;
            border-radius: 4px;
            background-color: #f8f8f8;
            font-size: 0.9rem;
        }
    </style>
</head>
<body>
    <h1>登录</h1>
    <form id="loginForm">
        <label>用户名: <input type="text" name="username"></label><br>
        <label>密码: <input type="password" name="password"></label><br>
        <button type="submit">登录</button>
    </form>
    <div id="result"></div>

    <script>
        document.getElementById('loginForm').addEventListener('submit', async (e) => {
            e.preventDefault();
            const formData = new FormData(e.target);
            const response = await fetch('/login', {
                method: 'POST',
                body: formData
            });
            const result = await response.json();
            document.getElementById('result').innerHTML = JSON.stringify(result, null, 2);
        });
    </script>
</body>
</html>